.POSIX:
PREFIX=	/usr/local
MANDIR=	man

SRC=	avas.c mtable.c
HDR=	memonic.h

default: avas
all: default README
install: default
	${INSTALL} -m 755 avas ${DESTDIR}${PREFIX}/bin/
	${INSTALL} -m 444 avas.1 ${DESTDIR}${PREFIX}/${MANDIR}/man1/
install-local: default
	${INSTALL} -m 755 avas ${HOME}/bin/
avas: ${SRC} ${HDR} Makefile
	${CC} ${CFLAGS} ${LFLAGS} -o $@ ${SRC}
mtable.c: mtable.txt
	./mtable.awk mtable.txt > $@
README: avas.1
	mandoc -Ios= -Tutf8 avas.1 |\
	    awk '{gsub(/.\b/,"");a=b;b=c;c=$$0}FNR>4{print a}' > $@
clean:
	rm -f mtable.c avas
clean-all: clean
	rm -f README
